<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>后台管理</title>
    <include file="Public:cssbase" />
    {%include 'admin/csbase.html'%}
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox">
            <div class="ibox-content">
                <form id="search" method="get" class="form-inline" autocomplete="off">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="pull-left">
                            <div class="btn-group">
                                <button type="button" class="btn btn-primary" onclick="adduser();" />
                                    <i class="fa fa-plus"></i> 添加
                                </button>
                                <a href="#" target="_blank" class="btn btn-danger">
                                    <i class="fa fa-file-excel-o"></i>   导出Excel
                                </a>
                            </div>
                        </div>
                        <div class="btn-group pull-right">
                            <button type="submit" class="btn btn-white">
                                <i class="fa fa-search"></i> 查询
                            </button>
                            <button type="button" class="btn btn-white" onclick="window.location.reload();">
                                <i class="fa fa-repeat"></i> 刷新
                            </button>
                        </div>
                        <div class="pull-right">
                            <select name="stype" id="stype" class="form-control">
                                <option value="username" >账号</option>
                                <option value="truename" >姓名</option>
                                <option value="mobile" >电话号码</option>
                                <option value="rename" >推荐人</option>
                            </select>
                            <input type="text" name="stext" id="stext" value="{$_GET['stext']}" class="form-control" />
                            &nbsp;
                        </div>
                    </div>
                </div>
                </form>
                <div class="table-responsive m-t-sm">
                    <table class="table table-striped table-hover">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>账号</th>
                                <th>姓名</th>
                                <th>电话号码</th>
                                <th>投资</th>
                                <th>推荐人</th>
                                <th>账户余额</th>
                                <th>挖矿收益</th>
                                <th>矿场收益</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {%if not userall%}
                            <tr>
                                <td colspan="14" style="text-align:center">暂无数据！</td>
                            </tr>
                            {%endif%}

                            {%for i in userall%}
                            <tr>
                                <td>{{i.id}}</td>
                                <td>{{i.username}}</td>
                                <td>{{i.first_name}}</td>
                                <td>{{i.phone}}</td>
                                <td>{{i.regmoney}}</td>
                                <td>{{i.reid}}</td>
                                <td>{{i.wallet}}</td>
                                <td>{{i.dig_income}}</td>
                                <td>{{i.ore_income}}</td>
                                
                                <td>
                                    <a link="{:U('User/useredit',array('id'=>$vo['id']))}" class="btn btn-xs btn-success edit"><i class="fa fa-edit"></i> 修改</a>
                                    <a href="{:U('User/gologin',array('id'=>$vo['id']))}" target="_blank" class="btn btn-xs btn-primary"><i class="fa fa-sign-in"></i> 登录</a>
                                </td>
                            </tr>
                            {%endfor%}

                        </tbody>
                    </table>
                    <div id="page"></div>
                </div>
            </div>
        </div>
    </div>
    
    <include file="Public:jsbase" />
    <script type="text/javascript">
    $(document).ready(function() {
        $("#page").pager({
            pagenumber: {$p},
            pagecount: {$pagesize},
            buttonClickCallback: PageClick
        });

        $("#allselect").click(function(){
            $("input[name='id[]']").prop("checked", $(this).prop("checked"));
        });
        
        $("body").on('change','.selectlevel',function(){
            var data = {
                uid : $(this).attr("data-id"),
                level : $(this).val()
            };
            layer.load(0,{shade: [0.2,'#000']});
            $.post("{:U('User/setlevel')}", data, function(re){
                layer.closeAll();
            });
        });

        $("body").on('change','.selectagentlevel',function(){
            var data = {
                uid : $(this).attr("data-id"),
                level : $(this).val()
            };
            layer.load(0,{shade: [0.2,'#000']});
            $.post("{:U('User/setagentlevel')}", data, function(re){
                layer.closeAll();
            });
        });
        
        $("body").on('click','.edit',function(){
            var link = $(this).attr("link");
            sc.opentab(link,'','',false);
        });
    });

    PageClick = function(p){
        sc.pageurl('','p',p);
    };
    
    setuserstatus = function(index,type,id){
        layer.load(0,{shade: [0.2,'#000']});
        $.post("{:U('User/setuserstatus')}",{'id':id,'type':type},function(re){
            layer.closeAll();
            if(re.code == 1){
                index.src = re.msg;
            }
        });
    }
    
    adduser = function(){
        sc.opentab("{:U('User/add')}",'','',false);
    }
    </script>
</body>
</html>